import os

from django.core.exceptions import ValidationError

def validate_file_extension(value):
    ext = os.path.splitext(value.name)[1]
    valid_extensions = ['.ogg', '.mp4']
    if not ext.lower() in valid_extensions:
        raise ValidationError(u'Please upload a video in mp4 or ogg format')